package com.dbq.fast.business.main.business;

import android.app.Activity;
import android.content.Intent;

import com.dbq.fast.common.bean.User;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by yuanchen on 2018/5/28.
 */

public class ExvBiz {

    private Activity activity;

    public ExvBiz(Activity context) {
        activity = context;
    }

    public void register() {
        if(activity == null) return;
        EventBus.getDefault().register(activity);
    }

    public void unregister() {
        if(activity == null) return;
        EventBus.getDefault().unregister(activity);
    }

    /**
     * 登录
     */
    public void login() {
        String data = "{\"partner_id\":\"188888888880\", \"version\":\"1.0.0\",\n" +
                "\"memo\":\"这个用户很重要\", \"identity_id\":\"%s\",\n" +
                "\"identity_type\":\"MOBILE\", \"nationality\":\"China\"}";

        String account = User.getInstance().getAccount();
        data = String.format(data, account);

        Intent intent = new Intent();
        intent.setAction("com.exv.coinex.service");
        intent.putExtra("task", "login");
        intent.putExtra("data", data);
        activity.startActivity(intent);
    }

//    /**
//     * 获取行情数据
//     */
//    public void accessMarketData() {
//        Intent intent = new Intent();
//        intent.setAction("com.exv.coinex.service");
//        intent.putExtra("partner_id", "188888888880");
//        intent.putExtra("task","requestCurrencies");
//        intent.putExtra("transPairs","BTC/WFee,BTC/USDT,ETH/BTC");
//        activity.startActivity(intent);
//    }
//
//
//    /**
//     * 断开获取行情数据
//     */
//    public void offMarketData() {
//        Intent intent = new Intent();
//        intent.setAction("com.exv.coinex.service");
//        intent.putExtra("task","finishRequestData");
//        activity.startActivity(intent);
//    }

}
